package com.weeego.web.service.impl;

import com.sql.weeego.bean.base.CenterNewsType;
import com.weeego.web.base.BaseServiceImpl;
import com.weeego.web.service.CentterNewsTypeService;
import java.io.Serializable;

/**
 *
 * @author zuaa
 */
public class CentterNewsTypeServiceImpl extends BaseServiceImpl implements CentterNewsTypeService {

    @Override
    public Serializable saveOrUpdate(Serializable serializable) {
        CenterNewsType _CenterNewsType = new CenterNewsType();
        _CenterNewsType = (CenterNewsType) serializable;
        if (_CenterNewsType == null) {
            return "error";
        } else {
            int a = 0;
            if (_CenterNewsType.getId() != null) {
                if (_CenterNewsType.getId() < 1) {
                    a = this.findByHql(" from CenterNewsType t where  t.typeKey like '" + _CenterNewsType.getTypeKey() + "'").size();
                } else {
                    a = this.findByHql(" from CenterNewsType t where t.id <> " + _CenterNewsType.getId() + " t.typeKey like '" + _CenterNewsType.getTypeKey() + "'").size();
                }
            } else {
                a = this.findByHql(" from CenterNewsType t where  t.typeKey like '" + _CenterNewsType.getTypeKey() + "'").size();
            }
            if (a < 1) {
                super.getBaseDao().saveOrUpdate(serializable);
                return "success";
            } else {
                logger.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                return "error";

            }
        }
    }
}
